﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Configuration;

public partial class admin_password_retrieval : Page
{
  
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        /*
        System.Threading.Thread.Sleep(3000);
        Users user = Users.Check_Email(txtEmail.Text.Trim());
        if (user != null)
        {
            string email = this.txtEmail.Text.Trim();
            string password = StringHelper.RandomString(8);
            Users u = new Users();
            u.UserID = user.UserID;
            u.UserName = user.UserName;
            u.Email = email;
            u.Password = password;
            if (Users.ChangeRecoveryPassword(u) > 0)
            {
                MailDefinition mailtemplate = new MailDefinition();
                mailtemplate.BodyFileName = "~/Templates/RecoveryPassword.htm";
                mailtemplate.Subject = String.Format("{0} - {1}", Settings.Setting("site.sitename"), "Khôi phục Password");
                mailtemplate.From = Settings.Setting("email.useremail");
                Dictionary<string, string> data = new Dictionary<string, string>();
                data.Add("<StoreName>", Settings.Setting("site.sitename"));
                data.Add("<username>", user.UserName);
                data.Add("<password>", password);
                data.Add("<email>", email);
                data.Add("<url>", Settings.Setting("site.siteurl"));

                MailMessage mail = mailtemplate.CreateMailMessage(email, data, new LiteralControl());

                MailModels _mail = new MailModels();
                _mail.MailMsg = mail;
                _mail.UserName = Settings.Setting("email.useremail"); //Ex: tuantipro (username is account your email)
                _mail.Password = Settings.Setting("email.password");
                _mail.UseDefaultCredentials = false;
                _mail.EnableSsl = true;
                _mail.Host = Settings.Setting("email.smtpserver");  // smpt server for gmail
                _mail.Port = Settings.SettingInt("email.smtpserverport"); ;
                if (MailServices.Send(_mail) == true)
                    Response.Redirect("~/admin/Login.aspx");
            }
            else
            {
                Log l = new Log() { Id = -1, Thread = "Login", Level = "ERROR", Logger = "Login", Message = u.UserName + "Change Password Fail", Exception = "" };
                Log.Add(l);

            }
        }
        else
        {
            Response.Redirect(Request.Url.AbsoluteUri);
        }
         * */
    }
}